package se.webbzon.oschi01.worldeditor;

import java.nio.ByteBuffer;

import se.webbzon.oschi01.worldobject.WorldMovableObject;
import se.webbzon.oschi01.worldobject.WorldObject;

public abstract class WorldMovableObjectDeflation extends WorldStaticObjectDeflation {
	
	private double vx,vy,vz;
	private double ax,ay,az;
	
	/*============================================================
	Constructors
	============================================================*/
	
	public WorldMovableObjectDeflation(	int deflationProperties,
										WorldObject[] dependencies) {
		super(deflationProperties,dependencies);
	}
	
	public WorldMovableObjectDeflation(	int deflationProperties, 
										WorldObject[] dependencies,
										WorldMovableObject instance) {
		super(deflationProperties,dependencies,instance);
		vx = instance.getXVelocity();
		vy = instance.getYVelocity();
		vz = instance.getZVelocity();
		ax = instance.getXAcceleration();
		ay = instance.getYAcceleration();
		az = instance.getZAcceleration();
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	/** Returns the x-velocity of this deflated movable world object. **/
	public double getXVelocity() {
		return vx;
	}
	
	/** Returns the y-velocity of this deflated movable world object. **/
	public double getYVelocity() {
		return vy;
	}
	
	/** Returns the z-velocity of this deflated movable world object. **/
	public double getZVelocity() {
		return vz;
	}
	
	/** Returns the x-acceleration of this deflated movable world object. **/
	public double getXAcceleration() {
		return ax;
	}
	
	/** Returns the y-velocity of this deflated movable world object. **/
	public double getYAcceleration() {
		return ay;
	}
	
	/** Returns the z-velocity of this deflated movable world object. **/
	public double getZAcceleration() {
		return az;
	}
	
	@Override public void inflate(ByteBuffer buff) {
		super.inflate(buff);
		vx = buff.getDouble();
		vy = buff.getDouble();
		vz = buff.getDouble();
		ax = buff.getDouble();
		ay = buff.getDouble();
		az = buff.getDouble();
	}

	@Override public ByteBuffer deflate(int allocate) {
		ByteBuffer buff = super.deflate(allocate + 48);
		
		buff.putDouble(vx);
		buff.putDouble(vy);
		buff.putDouble(vz);
		buff.putDouble(ax);
		buff.putDouble(ay);
		buff.putDouble(az);
		
		return buff;
	}

}
